| Conditions | 1 |
| Paths | 2 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | "use strict"; |
||
| 3 | module.exports = (arr_, pred) => { |
||
| 4 | |||
| 5 | const arr = arr_ || [], |
||
| 6 | spans = [] |
||
| 7 | |||
| 8 | let span = { label: undefined, |
||
| 9 | items: [arr.first] } |
||
| 10 | |||
| 11 | arr.forEach (x => { |
||
| 12 | |||
| 13 | const label = pred (x) |
||
| 14 | |||
| 15 | if ((span.label !== label) && span.items.length) { |
||
| 16 | spans.push (span = { label: label, items: [x] }) } |
||
| 17 | |||
| 18 | else { |
||
| 19 | span.items.push (x) } }) |
||
| 20 | |||
| 21 | return spans |
||
| 22 | } |